﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PluginInterface;
using System.Drawing;

namespace Buccontrols
{
    public enum Direction { North, South, East, West }

    public class PluginCouple
    {
        PluginCouple parent;
        IPlugin instance;
        List<PluginCouple> offspring;
        Direction direction;
        Size size;
        
        /// <summary>
        /// Construct a PluginCouple
        /// </summary>
        /// <param name="parent">the parent PluginCouple </param>
        public PluginCouple(PluginCouple parent)
        {
            this.parent = parent;
            this.offspring = new List<PluginCouple>();
            this.direction = Direction.East;
        }

        public PluginCouple(PluginCouple parent, IPlugin plugin)
        {
            this.parent = parent;
            this.instance = plugin;
            this.offspring = new List<PluginCouple>();
            this.direction = Direction.East;
        }

        /// <summary>
        /// The parent of the offspring in this PluginCouple
        /// </summary>
        public PluginCouple Parent
        {
            get { return this.parent; }
        }

        /// <summary>
        /// The instance of the plugin which forms the base of the couple
        /// </summary>
        public IPlugin Instance
        {
            get { return this.instance; }
        }

        /// <summary>
        /// The offspring of the parent in this PluginCouple
        /// </summary>
        public List<PluginCouple> Offspring
        {
            get { return this.offspring; }
        }

        /// <summary>
        /// The size of the Instance and it's offspring
        /// </summary>
        public Size Size
        {
            get { return this.size; }
        }

        /// <summary>
        /// The relative position towards the parent
        /// </summary>
        public Direction RelativePosition
        {
            get { return this.direction; }
            set { this.direction = value; }
        }

        /// <summary>
        /// Generate new offspring PluginCouple
        /// </summary>
        public void Generate()
        {
            this.offspring.Add(new PluginCouple(this));
        }

        public void Generate(IPlugin plugin)
        {
            this.offspring.Add(new PluginCouple(this, plugin));
        }
    }
}
